<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${ctx}/css/index_work.css">
    <script src="${ctx}/bootstrap/jquery-1.9.1.min.js"></script>
</head>
<body>
<form action="${ctx}/save.do">
    <input type="hidden" name="id" value="${tscenics.id}">
    名称<input type="text" name="name" value="${tscenics.name}"><br>

    省市<select name="provice_id" onchange="getshi()">
    <option value="">请选择</option>
</select>

    市级<select name="city_id" onchange="getxian()">
    <option value="">请选择</option>
</select>

    县级<select name="area_id" >
    <option value="">请选择</option>
</select><br>

    地区<input type="text" name="address" value="${tscenics.address}"><br>

        <input type="submit" value="提交">
</form>
</body>
<script>

    $.post("${ctx}/getTarea.do?pid=0",function(date) {
        for (var i in date) {
            $('[name="provice_id"]').append('<option value="'+date[i].id+'">'+date[i].name+'</option>')
        }
        $('[name="provice_id"]').val(${tscenics.id})
        getshi();
    },"json")

    function getshi() {
        var pid = $('[name="provice_id"]').val();
        $.post("${ctx}/getTarea.do?pid="+pid,function(date) {
            $('[name="city_id"]').html('<option value="">请选择</option>')
            for (var i in date) {
                $('[name="city_id"]').append('<option value="'+date[i].id+'">'+date[i].name+'</option>')
            }
            $('[name="city_id"]').val(${tscenics.id})
            getxian();
        },"json")
    }
    function getxian() {
        var pid = $('[name="city_id"]').val();
        $.post("${ctx}/getTarea.do?pid="+pid,function(date) {
            $('[name="area_id"]').html('<option value="">请选择</option>')
            for (var i in date) {
                $('[name="area_id"]').append('<option value="'+date[i].id+'">'+date[i].name+'</option>')
            }
            $('[name="area_id"]').val(${tscenics.id})
        },"json")
    }
</script>
</html>